/*!
 * Ext JS Library 3.1.1
 * Copyright(c) 2006-2010 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.onReady(function() {
	Ext.QuickTips.init();
    
    // create some portlet tools using built in Ext tool ids
    var tools = [{
        id:'gear',
        handler: function(){
            Ext.Msg.alert('Message', 'The Settings tool was clicked.');
        }
    },{
        id:'close',
        handler: function(e, target, panel){
            panel.ownerCt.remove(panel, true);
        }
    }];

    var hostpage = 'index.php/hosts/';
    var commandpage = 'index.php/commands/';
    var templatepage = 'index.php/templates/';
    var hostbindings = 'index.php/main/hostbindings';
    var commandbindings = 'index.php/main/commandbindings/';

    var refreshTab=function(tab){
	tab.getUpdater().refresh();
    };

    var viewport = new Ext.Viewport({
        layout:'fit',
        items:[{
            xtype: 'grouptabpanel',
    	    tabWidth: 180,
    	    activeGroup: 0,
    	    items: [{
    		mainItem: 1,
    		items: [{
    		    title: 'Host List',
                    layout: 'fit',
                    iconCls: 'x-icon-tickets',
                    tabTip: 'Tickets tabtip',
                    style: 'padding: 10px;',
		    deferredRender: true,
		    listeners: {activate: refreshTab},
		    items: {
			xtype          : 'iframepanel',
			defaultSrc  : hostpage
		    }	
    		}, 
			{
			    title: 'Host Control',
			    iconCls: 'x-icon-tickets',
			    tabTip: 'Tickets tabtip',
			    style: 'padding: 10px;',
			    html: Ext.example.shortHostControlMarkup
			}, 
			{
    			    title: 'Template Controls',
			    iconCls: 'x-icon-subscriptions',
			    tabTip: 'Subscriptions tabtip',
			    style: 'padding: 10px;',
			    layout: 'fit',
			    items: [
				{
				    xtype: 'tabpanel',
				    plain: true,
				    region: 'center',
				    margins: '0 5 5 5',
				    activeTab: 0,
				    autoScroll: true,
				    animScroll: true,
				    items: [
					{
					    title: 'Templates',
					    deferredRender: true,
					    layout : 'fit',
					    listeners: {activate: refreshTab},
					    items: {
						xtype: 'iframepanel',
						defaultSrc: templatepage
					    },
					    shim:false,
					    frame:true,
					    animCollapse:false,
					    enableTabScroll:true,
					    autoScroll:true
					},
					{
                                            title: 'Hosts Bindings',
                                            deferredRender: true,
                                            layout : 'fit',
                                            listeners: {activate: refreshTab},
                                            items: {
                                                xtype: 'iframepanel',
                                                defaultSrc: hostbindings
                                            },
                                            shim:false,
                                            frame:true,
                                            animCollapse:false,
                                            enableTabScroll:true,
                                            autoScroll:true
                                        },
					{
                                            title: 'Command Bindings',
                                            deferredRender: true,
                                            layout : 'fit',
                                            listeners: {activate: refreshTab},
                                            items: {
                                                xtype: 'iframepanel',
                                                defaultSrc: commandbindings
                                            },
                                            shim:false,
                                            frame:true,
                                            animCollapse:false,
                                            enableTabScroll:true,
                                            autoScroll:true
                                        }
				    ]
				}
				]			    
    			    }, 
			    {
    			    title: 'Access Report',
			    iconCls: 'x-icon-users',
			    tabTip: 'Users tabtip',
			    style: 'padding: 10px;',
    			    html: Ext.example.AccessPlaceHolder			
    			}]
            }, {
                expanded: true,
                items: [{
                    title: 'Command Control',
                    iconCls: 'x-icon-configuration',
                    tabTip: 'Configuration tabtip',
                    style: 'padding: 10px;',
		    layout: 'fit',
		    deferredRender: true,
                    listeners: {activate: refreshTab},
                    items: {
                        xtype          : 'iframepanel',
                        defaultSrc  : commandpage
                    }
                }, {
                    title: 'Datum',
                    iconCls: 'x-icon-templates',
                    tabTip: 'Datum information',
                    style: 'padding: 10px;',
                    html: Ext.example.shortBogusMarkup
                }]
            }]
	}]
    });
});
